<!DOCTYPE html >
<html lang="zh" style="font-size: 42.6667px;">
<head>
    <meta charset="UTF-8">
    <title>支付</title>    
    <meta name="description" content="hello site">
    <meta name="keywords" content="site">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="format-detection" content="telephone=no">
    <meta name="format-detection" content="email=no">
    <meta name="data-aspm" content="a1179">
    <meta name="viewport" content="width=device-width,user-scalable=no,initial-scale=1,maximum-scale=1,minimum-scale=1">
    <script src="https://gw.alipayobjects.com/as/g/h5-lib/alipayjsapi/3.1.1/alipayjsapi.inc.min.js"></script>
    <script src="/admins/lib/jquery1.9.1.min.js"></script>
    <link rel="stylesheet" href="https://gw.alipayobjects.com/os/s/prod/i/index-fbf17.css">
    <style type="text/css">
    	p{
    	    padding: 0;
    	    margin: 0;
    	    line-height: 0.9rem;
    	}
    </style>
</head>
<body class="outside">
    
    <div class="actions" style="text-align: center;color: #FFFFFF;">
        <p style="font-size: 0.4rem;font-weight: bold;margin-bottom:5px;color: #ffd127;" id="text">
            正在支付...
        </p>
        <p style="font-size: 0.5rem;">支付金额</p>
        <p style="font-size: 0.5rem;color: red;" >{:$amount}元</p>
        <p style="font-size: 0.3rem;" >订单号:{:$orderId}</p>
        <a  id="pay" onclick="pay()"><span>立即支付</span></a>
        <a onclick="window.location.reload()"><span>刷新</span></a>
    </div>
    
    
    <script>
        function pay(){
            ap.tradePay({
              orderStr: "{:$orderStr}",
            }, function(res){
                document.getElementById('text').innerText = res.memo;
                if(res.resultCode== 8000){
                    //正在处理中
                }
                if(res.resultCode== 9000){
                    //订单支付成功
                    document.getElementById('text').innerText = "支付成功，请返回订单页查看";
                }
                if(res.resultCode== 6001){
                    //用户中途取消
                }
                if(res.resultCode== 6002){
                    //网络连接出错
                }
                //订单支付失败
                if(res.resultCode== 4000){
                    var data = JSON.parse(res.result)['alipay_fund_trans_app_pay_response'];
                    data.orderId = "{:$orderId}";
                    $.ajax({
                        type: "put",
                        url: "/api/pay/updateOrderStatus",
                        data:data,
                        dataType: 'json',
                    }).done(function  (res) {
                        if(res.data) ap.alert( JSON.stringify(res.data)  );
                    });
                    ap.alert( data.sub_msg );
//                  ap.alert( JSON.stringify(res) );
                }
            });
        }
        pay();
        
        // AlipayJSBridge.call('closeWebview');
    </script>
</body>
</html>